package com.gthncz;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.gthncz.beans.HelloChina;
import com.gthncz.beans.HelloWorld;

public class BeanExtendsDemo {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		AbstractApplicationContext context = new ClassPathXmlApplicationContext("Beans_extends.xml");
		HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorld");
		System.out.println(" helloWorld' Msg : " + helloWorld.getMsg());
		HelloChina helloChina = (HelloChina) context.getBean("helloChina");
		System.out.println(" helloChina' Msg : " + helloChina.getMsg());
		System.out.println(" helloChina' Msg2 : " + helloChina.getMsg2());
		
		helloChina.setMsg("Hello GT!");
		System.out.println(" helloWorld' Msg : " + helloWorld.getMsg());  // 子类的属性赋值并没有改变父类上属性的值
		System.out.println(" helloChina' Msg : " + helloChina.getMsg());  
		
		context.registerShutdownHook();
	}
	
}
